<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="/assets/jquery/jquery-3.1.1.min.js"></script>
	<script src="/assets/layui-2.9.18/layui.js"></script>
	<link rel="stylesheet" href="/assets/layui-2.9.18/css/layui.css">
	<link rel="stylesheet" href="/assets/layui-2.9.18/css/admin.css">
	<script src="/assets/september/common.js"></script>
	<script src="/assets/september/htmlBuilder.js"></script>
	<script src="/assets/september/search.js"></script>
	<link rel="stylesheet" href="/assets/pages/list.css">
</head>
<body class="layui-layout-body">
<div id="LAY_app">
    <div class="layui-layout layui-layout-admin">
   		<div class="layui-fluid" style="height: 100%">
            <div class="layui-card" style="height:800px">
                <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item" style="height: 44px;clear: none">
                        <div class="layui-inline">
                            <label class="layui-search-form-label " style="display: inline">名称</label>
                            <div class="layui-search-input-inline">
                                <input type="text" name="name" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
							<label class="layui-search-form-label">层级</label>
							<div class="layui-search-input-inline">
								<select name="type">
									<option value="">全部</option>
									<option value="1">省</option>
									<option value="2">市</option>
									<option value="3">区县</option>
									<option value="4">乡镇</option>
								</select>
							</div>
						</div>
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-list" lay-submit
                                    lay-filter="LAY-app-contlist-search" onclick="doSearch(1);">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                        </div>
                        <#if user.hasPermission(RegionController.Init_Action)>
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-list" onclick="doInit();">初始化</button>
                        </div>
                        </#if>
                    </div>
                </div>
                <div class="layui-card-body" style="">

                    <div id="form" class="layui-table-box layui-form" >
                        <table id="LAY-app-content-list" lay-filter="LAY-app-content-list" class="layui-table">
                            <thead>
                            <tr>
                                <td align="center"><span>id</span></td>
                                <td align="center"><span>名称</span></td>
                                <td align="center"><span>编码</span></td>
                                <td align="center"><span>层级</span></td>
                                <td align="center"><span>上级</span></td>
                                <td align="center"><span>是否启用</span></td>
                                <th data-minwidth="150" class=" layui-table-col-special">
                                    <div class="layui-table-cell" align="center">
                                        <span>操作</span>
                                    </div>
                                </th>
                            </tr>
                            </thead>
                            <tbody class="layui-table-body layui-table-main">
                            <tr class="data_row" style="display: none">
                                <td align="center"><span>$[id]</span></td>
                                <td align="center"><span>$[name]</span></td>
                                <td align="center"><span>$[zipCode]</span></td>
                                <td align="center"><span>$[type]</span></td>
                                <td align="center"><span>$[parentId]</span></td>
                                <td align="center"><span>$[enableFlag]</span></td>
                                <td align="center" data-minwidth="150" class="layui-table-col-special">
                                    <div class="layui-table-cell">
                                    	<#if user.hasPermission(RegionController.Delete_Action)>
                                        <a class="layui-btn layui-btn-danger layui-btn-xs" onclick="deleteRegion($[id])">删除</a>
                                        </#if>
                                    </div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body">
                        <div id="page"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    searchUrl = '/pisces/region/listRegionData';
    layui.use(function(){
    	var layer = layui.layer;
    	doSearch(1);
  	});

    function doInit() {
        confirm('初始化数据将情况现有数据，是否继续？',function () {
            sajax({
                type: "POST",
                url: "/pisces/region/doInit",
                success: function (data) {
                    doPage(currentPage);
                    layer.msg('删除成功');
                }
            });
        });
    }

	function deleteRegion(currentId) {
        confirmDelete(function () {
            sajax({
                type: "POST",
                url: "/pisces/region/delete",
                data: {id: currentId},
                dataType: 'json',
                success: function (data) {
                    if (data.code == -1) {
                        layer.msg(data.desc);
                    } else {
                        layer.msg('删除成功');
                    }
                }
            });
        });
    }
    
</script>
</body>
</html>
